This file is used to analyse the IFE granular and spinous dataset.
library(dplyr)
library(patchwork)
library(ggplot2)
library(ComplexHeatmap)
.libPaths()
## [1] "/home/nf1/R/x86_64-pc-linux-gnu-library/3.6"
## [2] "/usr/local/lib/R/library"
In this section, we set the global settings of the analysis. We will store data there :
save_name = "ifegs"
out_dir = "."
We load the dataset :
sobj = readRDS(paste0(out_dir, "/", save_name, "_sobj.rds"))
sobj
## An object of class Seurat
## 14702 features across 858 samples within 1 assay
## Active assay: RNA (14702 features, 2000 variable features)
## 6 dimensional reductions calculated: RNA_pca, RNA_pca_23_tsne, RNA_pca_23_umap, harmony, harmony_23_umap, harmony_23_tsne
We load the sample information :
sample_info = readRDS(paste0(out_dir, "/../../1_metadata/hs_hd_sample_info.rds"))
project_names_oi = sample_info$project_name
graphics::pie(rep(1, nrow(sample_info)),
col = sample_info$color,
labels = sample_info$project_name)
Here are custom colors for each cell type :
color_markers = readRDS(paste0(out_dir, "/../../1_metadata/hs_hd_color_markers.rds"))
data.frame(cell_type = names(color_markers),
color = unlist(color_markers)) %>%
ggplot2::ggplot(., aes(x = cell_type, y = 0, fill = cell_type)) +
ggplot2::geom_point(pch = 21, size = 5) +
ggplot2::scale_fill_manual(values = unlist(color_markers), breaks = names(color_markers)) +
ggplot2::theme_classic() +
ggplot2::theme(legend.position = "none",
axis.line = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank(),
axis.text.y = element_blank(),
axis.text.x = element_text(angle = 30, hjust = 1))
This is the projection of interest :
name2D = "harmony_23_tsne"
We design a custom function to make the GSEA plot and a word cloud graph :
make_gsea_plot = function(gsea_results, gs_oi, fold_change, metric = "FC") {
fold_change$metric = fold_change[, metric]
plot_list = lapply(gs_oi, FUN = function(gene_set) {
# Gene set content
gs_content = gene_sets %>%
dplyr::filter(gs_name == gene_set) %>%
dplyr::pull(ensembl_gene) %>%
unique()
# Gene set size
nb_genes = length(gs_content)
# Enrichment metrics
NES = gsea_results@result[gene_set, "NES"]
p.adjust = gsea_results@result[gene_set, "p.adjust"] %>%
round(., 4)
qvalues = gsea_results@result[gene_set, "qvalues"]
if (p.adjust > 0.05) {
p.adjust = paste0("<span style='color:red;'>", p.adjust, "</span>")
}
my_subtitle = paste0("\nNES : ", round(NES, 2),
" | padj : ", p.adjust,
" | qval : ", round(qvalues, 4),
" | set size : ", nb_genes, " genes")
# Size limits
lower_FC = min(fold_change[gs_content, ]$metric, na.rm = TRUE)
upper_FC = max(fold_change[gs_content, ]$metric, na.rm = TRUE)
# Plot
p = enrichplot::gseaplot2(x = gsea_results, geneSetID = gene_set) +
ggplot2::labs(title = gene_set,
subtitle = my_subtitle) +
ggplot2::theme(plot.title = element_text(hjust = 0.5, face = "bold",
margin = ggplot2::margin(3, 3, 5, 3)),
plot.subtitle = ggtext::element_markdown(hjust = 0.5,
size = 10))
wc = ggplot2::ggplot(fold_change[gs_content, ],
aes(label = gene_name, size = abs(metric), color = metric)) +
ggwordcloud::geom_text_wordcloud_area(show.legend = TRUE) +
ggplot2::scale_color_gradient2(
name = metric,
low = aquarius::color_cnv[1],
mid = "gray70", midpoint = 0,
high = aquarius::color_cnv[3]) +
ggplot2::scale_size_area(max_size = 7) +
ggplot2::theme_minimal() +
ggplot2::guides(size = "none")
return(list(p, wc))
}) %>% unlist(., recursive = FALSE)
return(plot_list)
}
We visualize gene expression for some markers :
features = c("percent.mt", "nFeature_RNA", "TOP2A",
"SPINK5", "KRT1", "KRTDAP")
plot_list = lapply(features, FUN = function(one_gene) {
Seurat::FeaturePlot(sobj, features = one_gene,
reduction = name2D) +
ggplot2::theme(aspect.ratio = 1) +
ggplot2::scale_color_gradientn(colors = aquarius::color_gene) +
Seurat::NoAxes()
})
patchwork::wrap_plots(plot_list, ncol = 3)
We visualize clusters :
cluster_plot = Seurat::DimPlot(sobj, reduction = name2D, label = TRUE) +
Seurat::NoAxes() +
ggplot2::theme(aspect.ratio = 1)
cluster_plot
KRT1 and KRTDAP being specifically expressed in IFE spinous, we make a cluster annotation:
sobj$cluster_type = ifelse(sobj$seurat_clusters %in% c(0,7,5),
yes = "IFE spinous",
no = "IFE granular")
sobj$cluster_type = ifelse(sobj$seurat_clusters == 10,
yes = "IFE proliferative",
no = sobj$cluster_type)
cluster_color = setNames(nm = c("IFE spinous", "IFE granular", "IFE proliferative"),
c("steelblue4", "lightskyblue", "gray50"))
We visualize the cluster annotation split by sample :
plot_list = aquarius::plot_split_dimred(sobj,
reduction = name2D,
split_by = "project_name",
group_by = "cluster_type",
split_color = setNames(sample_info$color,
nm = sample_info$project_name),
group_color = cluster_color,
bg_pt_size = 0.5, main_pt_size = 0.5)
plot_list[[length(plot_list) + 1]] = Seurat::DimPlot(sobj, reduction = name2D,
group.by = "cluster_type") +
ggplot2::scale_color_manual(values = cluster_color,
breaks = names(cluster_color)) +
Seurat::NoAxes() +
ggplot2::theme(aspect.ratio = 1)
patchwork::wrap_plots(plot_list, ncol = 4) &
Seurat::NoLegend()
We save the results in a list :
list_results = list()
We make over-representation analysis for each group of genes. We load gene sets from MSigDB :
gene_sets = aquarius::get_gene_sets(species = "Homo sapiens")
gene_sets = gene_sets$gene_sets
head(gene_sets)
## # A tibble: 6 × 16
## gs_cat gs_subcat gs_name gene_symbol entrez_gene ensembl_gene human_gene_symb…
## <chr> <chr> <chr> <chr> <int> <chr> <chr>
## 1 C5 GO:BP GOBP_1… AASDHPPT 60496 ENSG0000014… AASDHPPT
## 2 C5 GO:BP GOBP_1… ALDH1L1 10840 ENSG0000014… ALDH1L1
## 3 C5 GO:BP GOBP_1… ALDH1L2 160428 ENSG0000013… ALDH1L2
## 4 C5 GO:BP GOBP_1… MTHFD1 4522 ENSG0000010… MTHFD1
## 5 C5 GO:BP GOBP_1… MTHFD1L 25902 ENSG0000012… MTHFD1L
## 6 C5 GO:BP GOBP_1… MTHFD2L 441024 ENSG0000016… MTHFD2L
## # … with 9 more variables: human_entrez_gene <int>, human_ensembl_gene <chr>,
## # gs_id <chr>, gs_pmid <chr>, gs_geoid <chr>, gs_exact_source <chr>,
## # gs_url <chr>, gs_description <chr>, category <chr>
How many gene sets ?
gene_sets[, c("gs_subcat", "gs_name")] %>%
dplyr::distinct() %>%
dplyr::pull(gs_subcat) %>%
table() %>%
as.data.frame.table() %>%
`colnames<-`(c("Category", "Nb gene sets"))
## Category Nb gene sets
## 1 50
## 2 CP:KEGG 186
## 3 CP:PID 196
## 4 CP:REACTOME 1615
## 5 CP:WIKIPATHWAYS 664
## 6 GO:BP 7658
## 7 GO:CC 1006
## 8 GO:MF 1738
We get gene name and gene ID correspondence :
gene_corresp = sobj@assays[["RNA"]]@meta.features[, c("gene_name", "Ensembl_ID")] %>%
`colnames<-`(c("NAME", "ID")) %>%
dplyr::mutate(ID = as.character(ID))
rownames(gene_corresp) = gene_corresp$ID
head(gene_corresp)
## NAME ID
## ENSG00000238009 AL627309.1 ENSG00000238009
## ENSG00000237491 AL669831.5 ENSG00000237491
## ENSG00000225880 LINC00115 ENSG00000225880
## ENSG00000230368 FAM41C ENSG00000230368
## ENSG00000230699 AL645608.3 ENSG00000230699
## ENSG00000187634 SAMD11 ENSG00000187634
We perform a differential expression analysis between granular and spinous clusters.
group_name = "granular_vs_spinous"
Seurat::Idents(sobj) = sobj$cluster_type
table(Seurat::Idents(sobj))
##
## IFE granular IFE spinous IFE proliferative
## 569 271 18
We identify DE genes between IFE granular and IFE spinous :
mark = Seurat::FindMarkers(sobj, ident.1 = "IFE granular", ident.2 = "IFE spinous")
mark = mark %>%
dplyr::filter(p_val_adj < 0.05) %>%
dplyr::arrange(-avg_logFC, pct.1 - pct.2)
list_results[[group_name]]$mark = mark
dim(mark)
## [1] 178 5
head(mark, n = 20)
## p_val avg_logFC pct.1 pct.2 p_val_adj
## CST6 1.312487e-08 2.7812181 0.232 0.081 1.929619e-04
## KRT17 3.146104e-54 2.3543550 0.888 0.513 4.625402e-50
## KRT6B 4.713061e-16 1.4782965 0.779 0.664 6.929142e-12
## SPRR1B 3.393337e-06 1.3897725 0.211 0.092 4.988884e-02
## PTN 2.499803e-38 1.1947052 0.698 0.310 3.675210e-34
## LGALS1 6.326597e-09 0.9863320 0.492 0.343 9.301364e-05
## S100A6 2.753732e-25 0.9788135 0.903 0.867 4.048537e-21
## APOE 7.514251e-45 0.9398667 0.935 0.819 1.104745e-40
## CALML3 1.374189e-31 0.9218625 0.926 0.749 2.020333e-27
## C1QTNF12 3.298999e-41 0.8318747 0.624 0.159 4.850188e-37
## CCL2 3.221356e-08 0.7510733 0.169 0.037 4.736038e-04
## CHI3L1 1.904183e-36 0.7379103 0.496 0.044 2.799530e-32
## S100A7 2.692190e-12 0.6861332 0.814 0.616 3.958058e-08
## S100A2 2.641968e-14 0.6805155 0.954 0.963 3.884221e-10
## CSTB 1.833595e-26 0.6404838 0.963 0.956 2.695751e-22
## CYP1B1 9.017717e-27 0.5955697 0.390 0.037 1.325785e-22
## DAPK2 1.466078e-27 0.5945600 0.573 0.255 2.155429e-23
## C9orf16 1.898308e-17 0.5918988 0.859 0.882 2.790893e-13
## CREG1 5.690539e-17 0.5881386 0.750 0.661 8.366230e-13
## CKB 4.937212e-11 0.5766541 0.640 0.513 7.258688e-07
We explore enrichment in gene sets for HS population.
genes_of_interest = mark %>%
dplyr::filter(avg_logFC > 0) %>%
rownames()
enrichr_results = aquarius::run_enrichr(gene_names = genes_of_interest,
gene_corresp = gene_corresp,
gene_sets = gene_sets[, c("gs_name", "ensembl_gene")],
make_plot = TRUE,
plot_title = "Up-regulated in IFE granular compared to IFE spinous")
list_results[[group_name]]$enrichr_hs = enrichr_results$ego
enrichr_results$plot +
ggplot2::theme(axis.text.y = element_text(size = 8))
We explore enrichment in gene sets for HD population.
genes_of_interest = mark %>%
dplyr::filter(avg_logFC < 0) %>%
rownames()
enrichr_results = aquarius::run_enrichr(gene_names = genes_of_interest,
gene_corresp = gene_corresp,
gene_sets = gene_sets[, c("gs_name", "ensembl_gene")],
make_plot = TRUE,
plot_title = "Down-regulated in IFE granular compared to IFE spinous")
list_results[[group_name]]$enrichr_hd = enrichr_results$ego
enrichr_results$plot +
ggplot2::theme(axis.text.y = element_text(size = 8))
We run a GSEA for all gene sets, from the full count matrix :
ranked_gene_list = aquarius::run_foldchange(Seurat::GetAssayData(sobj, assay = "RNA", slot = "counts"),
group1 = colnames(sobj)[sobj@active.ident %in% "IFE granular"],
group2 = colnames(sobj)[sobj@active.ident %in% "IFE spinous"])
names(ranked_gene_list) = gene_corresp$ID
gsea_results = aquarius::gsea_run(ranked_gene_list = ranked_gene_list,
gene_sets = gene_sets[, c("gs_name", "ensembl_gene")],
GSEA_p_val_thresh = 1)
list_results[[group_name]]$gsea = gsea_results
gsea_results@result %>%
dplyr::filter(pvalue < 0.05) %>%
dplyr::top_n(., n = 200, wt = abs(NES)) %>%
dplyr::mutate(too_long = ifelse(nchar(ID) > 60, yes = TRUE, no = FALSE)) %>%
dplyr::mutate(ID = stringr::str_sub(ID, end = 60)) %>%
dplyr::mutate(ID = ifelse(too_long, yes = paste0(ID, "..."), no = ID)) %>%
aquarius::gsea_plot(show_legend = TRUE) +
ggplot2::labs(title = "GSEA using all genes (count matrix)") +
ggplot2::theme(plot.title = element_text(size = 20))
We compute a fold change table to make a wordcloud :
fold_change = gene_corresp
colnames(fold_change) = c("gene_name", "ID")
rownames(fold_change) = fold_change$ID
fold_change$FC = ranked_gene_list[rownames(fold_change)]
fold_change$pct.1 = Seurat::GetAssayData(sobj, assay = "RNA",
slot = "counts")[, sobj@active.ident == "IFE granular"] %>%
apply(., MARGIN = 1, FUN = function(one_row) {
return( mean(one_row != 0) )
})
fold_change$pct.2 = Seurat::GetAssayData(sobj, assay = "RNA",
slot = "counts")[, sobj@active.ident == "IFE spinous"] %>%
apply(., MARGIN = 1, FUN = function(one_row) {
return( mean(one_row != 0) )
})
fold_change$FC_x_pct = ifelse(fold_change$FC > 0,
yes = fold_change$FC * fold_change$pct.1,
no = fold_change$FC * fold_change$pct.2)
dim(fold_change) ; head(fold_change)
## [1] 14702 6
## gene_name ID FC pct.1 pct.2
## ENSG00000238009 AL627309.1 ENSG00000238009 -1.6543733 0.003514938 0.01845018
## ENSG00000237491 AL669831.5 ENSG00000237491 -0.5753017 0.105448155 0.21771218
## ENSG00000225880 LINC00115 ENSG00000225880 -1.1568736 0.038664323 0.11439114
## ENSG00000230368 FAM41C ENSG00000230368 0.3025580 0.049209139 0.05904059
## ENSG00000230699 AL645608.3 ENSG00000230699 -0.1398001 0.015817223 0.02214022
## ENSG00000187634 SAMD11 ENSG00000187634 -1.2393358 0.005272408 0.01845018
## FC_x_pct
## ENSG00000238009 -0.030523492
## ENSG00000237491 -0.125250187
## ENSG00000225880 -0.132336097
## ENSG00000230368 0.014888619
## ENSG00000230699 -0.003095205
## ENSG00000187634 -0.022865974
We make the gsea plot for some gene sets :
gs_oi = c("GOBP_KERATINIZATION",
"GOCC_CORNIFIED_ENVELOPE",
"GOBP_CELLULAR_RESPONSE_TO_COPPER_ION",
"GOBP_CELLULAR_RESPONSE_TO_CADMIUM_ION",
"REACTOME_RESPONSE_TO_METAL_IONS",
"WP_TGFBETA_RECEPTOR_SIGNALING")
plot_list = make_gsea_plot(gsea_results, gs_oi, fold_change, "FC_x_pct")
patchwork::wrap_plots(plot_list, ncol = 2, widths = c(2,1.5))
We perform a differential expression analysis for all clusters, between HS patients (HS) and healthy donors (HD).
group_name = "HS_vs_HD"
Seurat::Idents(sobj) = sobj$sample_type
table(Seurat::Idents(sobj))
##
## HS HD
## 745 113
We identify DE genes between HS and HD :
mark = Seurat::FindMarkers(sobj, ident.1 = "HS", ident.2 = "HD")
mark = mark %>%
dplyr::filter(p_val_adj < 0.05) %>%
dplyr::arrange(-avg_logFC, pct.1 - pct.2)
list_results[[group_name]]$mark = mark
dim(mark)
## [1] 121 5
head(mark, n = 20)
## p_val avg_logFC pct.1 pct.2 p_val_adj
## LGALS7 1.570129e-18 1.5442230 0.626 0.248 2.308404e-14
## LGALS7B 1.397267e-18 1.4997898 0.890 0.796 2.054262e-14
## S100A7 5.847206e-22 1.4868877 0.819 0.336 8.596562e-18
## SERPINB4 8.588334e-09 1.2839572 0.289 0.035 1.262657e-04
## KRT16 3.200379e-09 1.1955128 0.560 0.230 4.705198e-05
## S100A9 1.536359e-17 1.1582099 0.879 0.549 2.258755e-13
## MIF 2.340242e-24 0.9700148 0.701 0.257 3.440623e-20
## FABP5 2.056235e-13 0.8558368 0.934 0.770 3.023076e-09
## SERPINB3 1.213844e-07 0.8363353 0.240 0.018 1.784594e-03
## AKR1B10 9.665634e-23 0.8159507 0.565 0.044 1.421041e-18
## RPS26 4.661145e-39 0.8095101 0.981 0.991 6.852815e-35
## MTRNR2L8 3.707886e-13 0.8073258 0.824 0.743 5.451334e-09
## S100A8 4.880448e-12 0.6928935 0.882 0.628 7.175235e-08
## CRABP2 1.178746e-08 0.5791768 0.713 0.460 1.732992e-04
## HSPA8 2.910521e-14 0.5533035 0.874 0.708 4.279048e-10
## MTRNR2L10 2.541018e-08 0.5521470 0.634 0.478 3.735805e-04
## ARF5 1.167134e-19 0.5149905 0.536 0.071 1.715921e-15
## XIST 2.830229e-09 0.4645008 0.612 0.292 4.161003e-05
## S100A2 1.054239e-08 0.4620684 0.964 0.920 1.549942e-04
## S100A10 7.344198e-11 0.4504742 0.948 0.867 1.079744e-06
We explore enrichment in gene sets for HS population.
genes_of_interest = mark %>%
dplyr::filter(avg_logFC > 0) %>%
rownames()
enrichr_results = aquarius::run_enrichr(gene_names = genes_of_interest,
gene_corresp = gene_corresp,
gene_sets = gene_sets[, c("gs_name", "ensembl_gene")],
make_plot = TRUE,
plot_title = "Up-regulated in HS compared to HD")
list_results[[group_name]]$enrichr_hs = enrichr_results$ego
enrichr_results$plot +
ggplot2::theme(axis.text.y = element_text(size = 8))
We explore enrichment in gene sets for HD population.
genes_of_interest = mark %>%
dplyr::filter(avg_logFC < 0) %>%
rownames()
enrichr_results = aquarius::run_enrichr(gene_names = genes_of_interest,
gene_corresp = gene_corresp,
gene_sets = gene_sets[, c("gs_name", "ensembl_gene")],
make_plot = TRUE,
plot_title = "Down-regulated in HS compared to HD")
list_results[[group_name]]$enrichr_hd = enrichr_results$ego
enrichr_results$plot +
ggplot2::theme(axis.text.y = element_text(size = 8))
We run a GSEA for all gene sets, from the full count matrix :
ranked_gene_list = aquarius::run_foldchange(Seurat::GetAssayData(sobj, assay = "RNA", slot = "counts"),
group1 = colnames(sobj)[sobj@active.ident %in% "HS"],
group2 = colnames(sobj)[sobj@active.ident %in% "HD"])
names(ranked_gene_list) = gene_corresp$ID
gsea_results = aquarius::gsea_run(ranked_gene_list = ranked_gene_list,
gene_sets = gene_sets[, c("gs_name", "ensembl_gene")],
GSEA_p_val_thresh = 1)
list_results[[group_name]]$gsea = gsea_results
gsea_results@result %>%
dplyr::filter(pvalue < 0.05) %>%
dplyr::top_n(., n = 200, wt = abs(NES)) %>%
dplyr::mutate(too_long = ifelse(nchar(ID) > 60, yes = TRUE, no = FALSE)) %>%
dplyr::mutate(ID = stringr::str_sub(ID, end = 60)) %>%
dplyr::mutate(ID = ifelse(too_long, yes = paste0(ID, "..."), no = ID)) %>%
aquarius::gsea_plot(show_legend = TRUE) +
ggplot2::labs(title = "GSEA using all genes (count matrix)") +
ggplot2::theme(plot.title = element_text(size = 20))
We compute a fold change table to make a wordcloud :
fold_change = gene_corresp
colnames(fold_change) = c("gene_name", "ID")
rownames(fold_change) = fold_change$ID
fold_change$FC = ranked_gene_list[rownames(fold_change)]
fold_change$pct.1 = Seurat::GetAssayData(sobj, assay = "RNA", slot = "counts")[, sobj@active.ident == "HS"] %>%
apply(., MARGIN = 1, FUN = function(one_row) {
return( mean(one_row != 0) )
})
fold_change$pct.2 = Seurat::GetAssayData(sobj, assay = "RNA", slot = "counts")[, sobj@active.ident == "HD"] %>%
apply(., MARGIN = 1, FUN = function(one_row) {
return( mean(one_row != 0) )
})
fold_change$FC_x_pct = ifelse(fold_change$FC > 0,
yes = fold_change$FC * fold_change$pct.1,
no = fold_change$FC * fold_change$pct.2)
dim(fold_change) ; head(fold_change)
## [1] 14702 6
## gene_name ID FC pct.1 pct.2
## ENSG00000238009 AL627309.1 ENSG00000238009 -0.31174748 0.010738255 0.000000000
## ENSG00000237491 AL669831.5 ENSG00000237491 0.06264803 0.153020134 0.079646018
## ENSG00000225880 LINC00115 ENSG00000225880 0.42521811 0.072483221 0.026548673
## ENSG00000230368 FAM41C ENSG00000230368 1.21876723 0.061744966 0.008849558
## ENSG00000230699 AL645608.3 ENSG00000230699 -0.57478189 0.018791946 0.008849558
## ENSG00000187634 SAMD11 ENSG00000187634 -3.67431756 0.005369128 0.035398230
## FC_x_pct
## ENSG00000238009 0.000000000
## ENSG00000237491 0.009586410
## ENSG00000225880 0.030821179
## ENSG00000230368 0.075252742
## ENSG00000230699 -0.005086565
## ENSG00000187634 -0.130064338
We make the gsea plot for some gene sets :
gs_oi = c("HALLMARK_INTERFERON_ALPHA_RESPONSE",
"HALLMARK_INTERFERON_GAMMA_RESPONSE",
"REACTOME_KERATINIZATION",
"GOBP_KERATINIZATION",
"GOBP_MACROPHAGE_CYTOKINE_PRODUCTION",
"GOCC_MHC_PROTEIN_COMPLEX",
"KEGG_ANTIGEN_PROCESSING_AND_PRESENTATION")
plot_list = make_gsea_plot(gsea_results, gs_oi, fold_change, "FC_x_pct")
patchwork::wrap_plots(plot_list, ncol = 2, widths = c(2,1.5))
We represent differentially expressed genes. First, we extract all DE genes :
features_oi = list_results[[group_name]]$mark %>%
dplyr::filter(p_val_adj < 0.05) %>%
dplyr::filter(pct.1 - pct.2 > 0.2 | abs(avg_logFC) > 1) %>%
rownames()
length(features_oi)
## [1] 29
We prepare the scaled expression matrix :
mat_expression = Seurat::GetAssayData(sobj, assay = "RNA", slot = "data")[features_oi, ]
mat_expression = Matrix::t(mat_expression)
mat_expression = dynutils::scale_quantile(mat_expression) # between 0 and 1
mat_expression = Matrix::t(mat_expression)
mat_expression = as.matrix(mat_expression) # not sparse
dim(mat_expression)
## [1] 29 858
We prepare the heatmap annotation :
ha_top = ComplexHeatmap::HeatmapAnnotation(
sample_type = sobj$sample_type,
cluster_type = sobj$cluster_type,
cluster = sobj$seurat_clusters,
col = list(sample_type = setNames(nm = c("HS", "HD"),
c("#C55F40", "#2C78E6")),
cluster_type = cluster_color,
cluster = setNames(nm = levels(sobj$seurat_clusters),
aquarius::gg_color_hue(length(levels(sobj$seurat_clusters))))))
And the heatmap :
ht = ComplexHeatmap::Heatmap(mat_expression,
col = aquarius::color_cnv,
# Annotation
top_annotation = ha_top,
# Grouping
column_order = sobj@meta.data %>%
dplyr::arrange(cluster_type, sample_type, seurat_clusters) %>%
rownames(),
column_title = NULL,
cluster_rows = FALSE,
cluster_columns = FALSE,
show_column_names = FALSE,
# Visual aspect
show_heatmap_legend = TRUE,
border = TRUE)
ComplexHeatmap::draw(ht,
merge_legend = TRUE,
heatmap_legend_side = "bottom",
annotation_legend_side = "bottom")
We save the list of results :
saveRDS(list_results, file = paste0(out_dir, "/", save_name, "_list_results.rds"))
## R version 3.6.3 (2020-02-29)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 24.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/local/lib/R/lib/libRblas.so
## LAPACK: /usr/local/lib/R/lib/libRlapack.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] grid stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] ComplexHeatmap_2.14.0 ggplot2_3.3.5 patchwork_1.1.2
## [4] dplyr_1.0.7
##
## loaded via a namespace (and not attached):
## [1] softImpute_1.4 graphlayouts_0.7.0
## [3] pbapply_1.4-2 lattice_0.20-41
## [5] haven_2.3.1 vctrs_0.3.8
## [7] usethis_2.0.1 dynwrap_1.2.1
## [9] blob_1.2.1 survival_3.2-13
## [11] prodlim_2019.11.13 dynutils_1.0.5
## [13] later_1.3.0 DBI_1.1.1
## [15] R.utils_2.11.0 SingleCellExperiment_1.8.0
## [17] rappdirs_0.3.3 uwot_0.1.8
## [19] dqrng_0.2.1 jpeg_0.1-8.1
## [21] zlibbioc_1.32.0 pspline_1.0-18
## [23] pcaMethods_1.78.0 mvtnorm_1.1-1
## [25] htmlwidgets_1.5.4 GlobalOptions_0.1.2
## [27] future_1.22.1 UpSetR_1.4.0
## [29] laeken_0.5.2 leiden_0.3.3
## [31] clustree_0.4.3 parallel_3.6.3
## [33] scater_1.14.6 irlba_2.3.3
## [35] markdown_1.1 DEoptimR_1.0-9
## [37] tidygraph_1.1.2 Rcpp_1.0.9
## [39] readr_2.0.2 KernSmooth_2.23-17
## [41] carrier_0.1.0 promises_1.1.0
## [43] gdata_2.18.0 DelayedArray_0.12.3
## [45] limma_3.42.2 graph_1.64.0
## [47] RcppParallel_5.1.9 Hmisc_4.4-0
## [49] fs_1.5.2 RSpectra_0.16-0
## [51] fastmatch_1.1-0 ranger_0.12.1
## [53] digest_0.6.25 png_0.1-7
## [55] sctransform_0.2.1 cowplot_1.0.0
## [57] DOSE_3.12.0 here_1.0.1
## [59] TInGa_0.0.0.9000 ggraph_2.0.3
## [61] pkgconfig_2.0.3 GO.db_3.10.0
## [63] DelayedMatrixStats_1.8.0 gower_0.2.1
## [65] ggbeeswarm_0.6.0 iterators_1.0.12
## [67] DropletUtils_1.6.1 reticulate_1.26
## [69] clusterProfiler_3.14.3 SummarizedExperiment_1.16.1
## [71] circlize_0.4.15 beeswarm_0.4.0
## [73] GetoptLong_1.0.5 xfun_0.35
## [75] bslib_0.3.1 zoo_1.8-10
## [77] tidyselect_1.1.0 reshape2_1.4.4
## [79] purrr_0.3.4 ica_1.0-2
## [81] pcaPP_1.9-73 viridisLite_0.3.0
## [83] rtracklayer_1.46.0 rlang_1.0.2
## [85] hexbin_1.28.1 jquerylib_0.1.4
## [87] dyneval_0.9.9 glue_1.4.2
## [89] RColorBrewer_1.1-2 matrixStats_0.56.0
## [91] stringr_1.4.0 lava_1.6.7
## [93] europepmc_0.3 DESeq2_1.26.0
## [95] recipes_0.1.17 labeling_0.3
## [97] httpuv_1.5.2 class_7.3-17
## [99] BiocNeighbors_1.4.2 DO.db_2.9
## [101] annotate_1.64.0 jsonlite_1.7.2
## [103] XVector_0.26.0 bit_4.0.4
## [105] mime_0.9 aquarius_0.1.5
## [107] Rsamtools_2.2.3 gridExtra_2.3
## [109] gplots_3.0.3 stringi_1.4.6
## [111] processx_3.5.2 gsl_2.1-6
## [113] bitops_1.0-6 cli_3.0.1
## [115] batchelor_1.2.4 RSQLite_2.2.0
## [117] randomForest_4.6-14 tidyr_1.1.4
## [119] data.table_1.14.2 rstudioapi_0.13
## [121] org.Mm.eg.db_3.10.0 GenomicAlignments_1.22.1
## [123] nlme_3.1-147 qvalue_2.18.0
## [125] scran_1.14.6 locfit_1.5-9.4
## [127] scDblFinder_1.1.8 listenv_0.8.0
## [129] ggthemes_4.2.4 gridGraphics_0.5-0
## [131] R.oo_1.24.0 dbplyr_1.4.4
## [133] BiocGenerics_0.32.0 TTR_0.24.2
## [135] readxl_1.3.1 lifecycle_1.0.1
## [137] timeDate_3043.102 ggpattern_0.3.1
## [139] munsell_0.5.0 cellranger_1.1.0
## [141] R.methodsS3_1.8.1 proxyC_0.1.5
## [143] visNetwork_2.0.9 caTools_1.18.0
## [145] codetools_0.2-16 ggwordcloud_0.5.0
## [147] Biobase_2.46.0 GenomeInfoDb_1.22.1
## [149] vipor_0.4.5 lmtest_0.9-38
## [151] msigdbr_7.5.1 htmlTable_1.13.3
## [153] triebeard_0.3.0 lsei_1.3-0
## [155] xtable_1.8-4 ROCR_1.0-7
## [157] BiocManager_1.30.10 scatterplot3d_0.3-41
## [159] abind_1.4-5 farver_2.0.3
## [161] parallelly_1.28.1 RANN_2.6.1
## [163] askpass_1.1 GenomicRanges_1.38.0
## [165] RcppAnnoy_0.0.16 tibble_3.1.5
## [167] ggdendro_0.1-20 cluster_2.1.0
## [169] future.apply_1.5.0 Seurat_3.1.5
## [171] dendextend_1.15.1 Matrix_1.3-2
## [173] ellipsis_0.3.2 prettyunits_1.1.1
## [175] lubridate_1.7.9 ggridges_0.5.2
## [177] igraph_1.2.5 RcppEigen_0.3.3.7.0
## [179] fgsea_1.12.0 remotes_2.4.2
## [181] scBFA_1.0.0 destiny_3.0.1
## [183] VIM_6.1.1 testthat_3.1.0
## [185] htmltools_0.5.2 BiocFileCache_1.10.2
## [187] yaml_2.2.1 utf8_1.1.4
## [189] plotly_4.9.2.1 XML_3.99-0.3
## [191] ModelMetrics_1.2.2.2 e1071_1.7-3
## [193] foreign_0.8-76 withr_2.5.0
## [195] fitdistrplus_1.0-14 BiocParallel_1.20.1
## [197] xgboost_1.4.1.1 bit64_4.0.5
## [199] foreach_1.5.0 robustbase_0.93-9
## [201] Biostrings_2.54.0 GOSemSim_2.13.1
## [203] rsvd_1.0.3 memoise_2.0.0
## [205] evaluate_0.18 forcats_0.5.0
## [207] rio_0.5.16 geneplotter_1.64.0
## [209] tzdb_0.1.2 caret_6.0-86
## [211] ps_1.6.0 DiagrammeR_1.0.6.1
## [213] curl_4.3 fdrtool_1.2.15
## [215] fansi_0.4.1 highr_0.8
## [217] urltools_1.7.3 xts_0.12.1
## [219] GSEABase_1.48.0 acepack_1.4.1
## [221] edgeR_3.28.1 checkmate_2.0.0
## [223] scds_1.2.0 cachem_1.0.6
## [225] npsurv_0.4-0 babelgene_22.3
## [227] rjson_0.2.20 openxlsx_4.1.5
## [229] ggrepel_0.9.1 clue_0.3-60
## [231] rprojroot_2.0.2 stabledist_0.7-1
## [233] tools_3.6.3 sass_0.4.0
## [235] nichenetr_1.1.1 magrittr_2.0.1
## [237] RCurl_1.98-1.2 proxy_0.4-24
## [239] car_3.0-11 ape_5.3
## [241] ggplotify_0.0.5 xml2_1.3.2
## [243] httr_1.4.2 assertthat_0.2.1
## [245] rmarkdown_2.18 boot_1.3-25
## [247] globals_0.14.0 R6_2.4.1
## [249] Rhdf5lib_1.8.0 nnet_7.3-14
## [251] RcppHNSW_0.2.0 progress_1.2.2
## [253] genefilter_1.68.0 statmod_1.4.34
## [255] gtools_3.8.2 shape_1.4.6
## [257] HDF5Array_1.14.4 BiocSingular_1.2.2
## [259] rhdf5_2.30.1 splines_3.6.3
## [261] AUCell_1.8.0 carData_3.0-4
## [263] colorspace_1.4-1 generics_0.1.0
## [265] stats4_3.6.3 base64enc_0.1-3
## [267] dynfeature_1.0.0 smoother_1.1
## [269] gridtext_0.1.1 pillar_1.6.3
## [271] tweenr_1.0.1 sp_1.4-1
## [273] ggplot.multistats_1.0.0 rvcheck_0.1.8
## [275] GenomeInfoDbData_1.2.2 plyr_1.8.6
## [277] gtable_0.3.0 zip_2.2.0
## [279] knitr_1.41 latticeExtra_0.6-29
## [281] biomaRt_2.42.1 IRanges_2.20.2
## [283] fastmap_1.1.0 ADGofTest_0.3
## [285] copula_1.0-0 doParallel_1.0.15
## [287] AnnotationDbi_1.48.0 vcd_1.4-8
## [289] babelwhale_1.0.1 openssl_1.4.1
## [291] scales_1.1.1 backports_1.2.1
## [293] S4Vectors_0.24.4 ipred_0.9-12
## [295] enrichplot_1.6.1 hms_1.1.1
## [297] ggforce_0.3.1 Rtsne_0.15
## [299] shiny_1.7.1 numDeriv_2016.8-1.1
## [301] polyclip_1.10-0 lazyeval_0.2.2
## [303] Formula_1.2-3 tsne_0.1-3
## [305] crayon_1.3.4 MASS_7.3-54
## [307] pROC_1.16.2 viridis_0.5.1
## [309] dynparam_1.0.0 rpart_4.1-15
## [311] zinbwave_1.8.0 compiler_3.6.3
## [313] ggtext_0.1.0